feat: markdown 表格闭合边框渲染 + CJK/emoji 宽度适配#115
Open
dengmik-commits wants to merge 2 commits into
Open
Conversation
- Detect markdown tables and render with Unicode box-drawing characters - Calculate visual terminal width for CJK/emoji (2 cols) vs ASCII (1 col) - Wrap long cells across multiple lines, prefer word-boundary breaks - Allocate column widths: narrow columns (#, status, count, date) minimal, content columns kept >= 12 chars - Render tables with <Text wrap="truncate-end"> to prevent Ink from breaking box-drawing lines at cell boundary spaces - Expose renderMarkdownSegments() for per-segment wrapping control
a717ff7 to
928551e
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

概述
当前 deepcode-cli 的 markdown 表格仅原样输出
| col1 | col2 |分隔符,排版简陋、宽度溢出时自动被 Ink 断行导致错乱。本次改动增加了闭合边框表格渲染、CJK 宽字符和 emoji 视觉宽度计算、单元格内自动换行,以及表格与普通文本分离渲染。效果
变更
src/ui/components/MessageView/markdown.tsvisualWidth(text)— 按终端列宽计算字符视觉宽度(CJK 字符、全角、emoji = 2 列,ASCII = 1 列)splitTableBlocks(text)— 从文本中检测和解析 markdown 表格(| col | col |+---|---)renderTableBorder(rows, maxWidth)— 渲染闭合边框表格:#、状态、评论、日期)优先压缩,内容列保有最少 12 字符renderMarkdownSegments(text, maxWidth)— 将文本拆分为text/table/code分段renderMarkdown()委托给renderMarkdownSegments()(向后兼容)src/ui/components/MessageView/index.tsxrenderMarkdownSegments()返回的分段数组<Text wrap="truncate-end">渲染,彻底杜绝 Ink 在单元格空格处断行<Text>默认 wrap,保持正常折行src/ui/index.tsrenderMarkdownSegments验证